home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / WinUtils.cpp < prev   
Encoding:
C/C++ Source or Header  |  1996-04-22  |  3.3 KB  |  149 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        WinUtils.cpp
  3.  
  4.     Contains:    Implementation of window utilities
  5.  
  6.     Owned by:    Richard Rodseth
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     
  11. */
  12.  
  13. #ifndef _ALTPOINT_
  14. #include "AltPoint.h"
  15. #endif
  16.  
  17. #ifndef _WINUTILS_
  18. #include "WinUtils.h"
  19. #endif
  20.  
  21. #ifndef SOM_ODDraft_xh
  22. #include "Draft.xh"
  23. #endif
  24.  
  25. #ifndef _ODUTILS_
  26. #include "ODUtils.h"
  27. #endif
  28.  
  29. #ifndef SOM_ODFrame_xh
  30. #include "Frame.xh"
  31. #endif
  32.  
  33. #ifndef _PASCLSTR_
  34. #include "PasclStr.h"
  35. #endif
  36.  
  37. #ifndef _EXCEPT_
  38. #include <Except.h>
  39. #endif
  40.  
  41. #ifndef _ODDEBUG_
  42. #include "ODDebug.h"
  43. #endif
  44.  
  45. #ifndef _ODMEMORY_
  46. #include <ODMemory.h>
  47. #endif
  48.  
  49. #ifndef SOM_ODStorageUnit_xh
  50. #include <StorageU.xh>
  51. #endif
  52.  
  53. #ifndef SOM_ODStorageUnitView_xh
  54. #include <SUView.xh>
  55. #endif
  56.  
  57. #ifndef _STDTYPIO_
  58. #include "StdTypIO.h"
  59. #endif
  60.  
  61. #ifndef _TEMPOBJ_
  62. #include <TempObj.h>
  63. #endif
  64.  
  65. #ifndef _STORUTIL_
  66. #include <StorUtil.h>
  67. #endif
  68.  
  69. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  70. #include <StdTypes.xh>
  71. #endif
  72.  
  73. #ifndef SOM_Module_OpenDoc_StdProps_defined
  74. #include <StdProps.xh>
  75. #endif
  76.  
  77.  
  78. ODBoolean BeginGetWindowProperties(Environment* ev, ODFrame* frame, WindowProperties* properties)
  79. {
  80.     ASSERT(frame != kODNULL, kODErrInvalidFrame);
  81.         
  82.     ODBoolean propsExist = kODFalse;
  83.         
  84.     ODStorageUnit* frameSU = frame->GetStorageUnit(ev);
  85.     ODStorageUnit* windowPropsSU = kODNULL;
  86.     
  87.     ODID id = ODGetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef);
  88.  
  89.     if (id != 0)
  90.     {
  91.         TRY
  92.         TempODStorageUnit windowPropsSU = frameSU->GetDraft(ev)->AcquireStorageUnit(ev,id);
  93.         if (windowPropsSU)
  94.         {
  95.             propsExist = kODTrue;
  96.             
  97.             ODRect odRect;
  98.             ODGetRectProp(ev, windowPropsSU, kODPropWindowRect, kODRect, &odRect);
  99.             odRect.AsQDRect(properties->boundsRect);        
  100.             
  101.             properties->title[0] = 0;
  102.             ODIText* iText = ODGetITextProp(ev, windowPropsSU, kODPropWindowTitle, kODMacIText, kODNULL);
  103.             if (iText)
  104.                 IntlToPStr(iText, &(properties->title[0])); 
  105.                                     //  No error checking is done for
  106.                                     //  strings longer than 255 chars. 
  107.             DisposeIText(iText);
  108.             
  109.             properties->procID = ODGetSShortProp(ev, 
  110.                 windowPropsSU, kODPropWindowProcID, kODSShort);
  111.             
  112.             properties->wasVisible = ODGetBooleanProp(ev, 
  113.                 windowPropsSU, kODPropWindowIsVisible, kODBoolean);
  114.             properties->hasCloseBox = ODGetBooleanProp(ev, 
  115.                 windowPropsSU, kODPropWindowHasCloseBox, kODBoolean);
  116.             properties->shouldShowLinks = ODGetBooleanProp(ev, 
  117.                 windowPropsSU, kODPropShouldShowLinks, kODBoolean);
  118.             
  119.             properties->refCon = ODGetSLongProp(ev, 
  120.                 windowPropsSU, kODPropWindowRefCon, kODSLong);
  121.             properties->isResizable = ODGetBooleanProp(ev, 
  122.                 windowPropsSU, kODPropWindowIsResizable, kODBoolean);
  123.             properties->isFloating = ODGetBooleanProp(ev, 
  124.                 windowPropsSU, kODPropWindowIsFloating, kODBoolean);
  125.             properties->isRootWindow = ODGetBooleanProp(ev, 
  126.                 windowPropsSU, kODPropWindowIsRootWindow, kODBoolean);
  127.             
  128.             properties->sourceFrame = kODNULL;
  129.             ODID id = ODGetStrongSURefProp(ev, 
  130.                 windowPropsSU, kODPropSourceFrame, kODStrongStorageUnitRef);
  131.             if (id != 0)
  132.             {
  133.                 properties->sourceFrame = windowPropsSU->GetDraft(ev)->AcquireFrame(ev,id);
  134.             }
  135.         }
  136.         CATCH_ALL
  137.             WARN("Frame has kODPropWindowProperties, but unable to retrieve ID for strong suref in it.");
  138.         ENDTRY
  139.     }
  140.     return propsExist;
  141. }
  142.  
  143. void EndGetWindowProperties(Environment* ev, WindowProperties* properties)
  144. {
  145.     if (properties)
  146.         ODReleaseObject(ev, properties->sourceFrame); 
  147. }
  148.  
  149.